home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWOSMisc / Include / FWAlert.h next >
Encoding:
Text File  |  1995-11-08  |  5.5 KB  |  177 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWAlert.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWALERT_H
  11. #define FWALERT_H
  12.  
  13. // ----- Foundation Includes -----
  14.  
  15. #ifndef FWCOMMON_H
  16. #include "FWCommon.h"
  17. #endif
  18.  
  19. #ifndef FWSTRING_H
  20. #include "FWString.h"
  21. #endif
  22.  
  23. // ----- Macintosh includes -----
  24.  
  25. #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
  26. #include <Types.h>
  27. #endif
  28.  
  29. #if defined(FW_BUILD_MAC) && !defined(__DIALOGS__)
  30. #include <Dialogs.h>
  31. #endif
  32.  
  33. #if defined(FW_BUILD_MAC) && !defined(__EVENTS__)
  34. #include <Events.h>
  35. #endif
  36.  
  37. // ----- Windows includes -----
  38.  
  39. #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWS)
  40. #include <Windows.h>
  41. #endif
  42.  
  43. #if FW_LIB_EXPORT_PRAGMAS
  44. #pragma lib_export on
  45. #endif
  46.  
  47. //========================================================================================
  48. //    Forward Declarations
  49. //========================================================================================
  50.  
  51. //========================================================================================
  52. //    Constants
  53. //========================================================================================
  54.  
  55. typedef short FW_AlertResult;
  56. typedef short FW_ButtonType;
  57. typedef short FW_IconType;
  58. typedef short FW_DefaultButton;
  59.  
  60. #ifdef FW_BUILD_MAC
  61. const FW_ButtonType FW_kOK                    = 0x0000;
  62. const FW_ButtonType FW_kOKCancel             = 0x0001;
  63. const FW_ButtonType FW_kAbortRetryIgnore     = 0x0002;
  64. const FW_ButtonType FW_kYesNoCancel         = 0x0003;
  65. const FW_ButtonType FW_kYesNo                 = 0x0004;
  66. const FW_ButtonType FW_kRetryCancel         = 0x0005;
  67.  
  68. const FW_IconType FW_kStopAlert             = 0x0010;
  69. const FW_IconType FW_kCautionAlert             = 0x0020;
  70. const FW_IconType FW_kNoteAlert             = 0x0040;
  71.     
  72. const FW_DefaultButton FW_kDefaultButton1     = 0x0000;
  73. const FW_DefaultButton FW_kDefaultButton2     = 0x0100;
  74. const FW_DefaultButton FW_kDefaultButton3     = 0x0200;
  75.     
  76. enum EAlertResultConstants
  77. {
  78.     FW_kOKButtonPressed         = 1,
  79.     FW_kCancelButtonPressed     = 2,
  80.     FW_kAbortButtonPressed         = 3,
  81.     FW_kRetryButtonPressed         = 4,
  82.     FW_kIgnoreButtonPressed     = 5,
  83.     FW_kYesButtonPressed         = 6,
  84.     FW_kNoButtonPressed         = 7
  85. };
  86. #endif
  87.  
  88. #ifdef FW_BUILD_WIN
  89. const FW_ButtonType FW_kOK                    = MB_OK;
  90. const FW_ButtonType FW_kOKCancel             = MB_OKCANCEL;
  91. const FW_ButtonType FW_kAbortRetryIgnore     = MB_ABORTRETRYIGNORE;
  92. const FW_ButtonType FW_kYesNoCancel         = MB_YESNOCANCEL;
  93. const FW_ButtonType FW_kYesNo                 = MB_YESNO;
  94. const FW_ButtonType FW_kRetryCancel         = MB_RETRYCANCEL;
  95.     
  96. const FW_IconType FW_kStopAlert                = MB_ICONHAND;
  97. const FW_IconType FW_kCautionAlert             = MB_ICONQUESTION;
  98. const FW_IconType FW_kNoteAlert             = MB_ICONASTERISK;
  99.     
  100. const FW_DefaultButton FW_kDefaultButton1     = MB_DEFBUTTON1;
  101. const FW_DefaultButton FW_kDefaultButton2     = MB_DEFBUTTON2;
  102. const FW_DefaultButton FW_kDefaultButton3     = MB_DEFBUTTON3;
  103.  
  104. enum EAlertResultConstants
  105. {
  106.     FW_kOKButtonPressed         = IDOK ,
  107.     FW_kCancelButtonPressed     = IDCANCEL,
  108.     FW_kAbortButtonPressed         = IDABORT ,
  109.     FW_kRetryButtonPressed         = IDRETRY,
  110.     FW_kIgnoreButtonPressed     = IDIGNORE,
  111.     FW_kYesButtonPressed         = IDYES,
  112.     FW_kNoButtonPressed         = IDNO
  113. };
  114. #endif
  115.     
  116. //========================================================================================
  117. // class FW_CAlert
  118. //========================================================================================
  119.  
  120. class FW_CLASS_ATTR FW_CAlert
  121. {
  122.     public:
  123.         static FW_AlertResult DoAlert(const FW_CString& documentName,
  124.                                         const FW_CString& message,
  125.                                         FW_ButtonType buttonType,
  126.                                         FW_IconType iconType,
  127.                                         FW_DefaultButton defaultButton,
  128.                                         FW_Boolean beep);
  129.                                         
  130.         static FW_AlertResult DoNote(const FW_CString& documentName, const FW_CString& message);
  131.         static FW_AlertResult DoQuestion(const FW_CString& documentName, const FW_CString& message, FW_DefaultButton defaultButton);
  132.         static FW_AlertResult DoError(const FW_CString& documentName, const FW_CString& message);
  133.     
  134. #ifdef FW_BUILD_MAC
  135.     public:
  136.         static pascal Boolean MacAlertDialogFilter(DialogPtr theDialog, 
  137.                                                     EventRecord *theEvent, 
  138.                                                     short *itemHit);
  139.  
  140.     private:
  141.         static short gOkItemId;
  142.         static short gCancelItemId;
  143. #endif
  144. };
  145.  
  146. //----------------------------------------------------------------------------------------
  147. //    DoNote
  148. //----------------------------------------------------------------------------------------
  149. inline FW_AlertResult FW_CAlert::DoNote(const FW_CString& documentName, const FW_CString& message)
  150. {
  151.     return DoAlert(documentName, message, FW_kOK, FW_kNoteAlert, FW_kDefaultButton1, TRUE);
  152. }
  153.  
  154. //----------------------------------------------------------------------------------------
  155. //    DoQuestion
  156. //----------------------------------------------------------------------------------------
  157. inline FW_AlertResult FW_CAlert::DoQuestion(const FW_CString& documentName, 
  158.                                             const FW_CString& message,
  159.                                             FW_DefaultButton defaultButton)
  160. {
  161.     return DoAlert(documentName, message, FW_kYesNo, FW_kCautionAlert, defaultButton, TRUE);
  162. }
  163.  
  164. //----------------------------------------------------------------------------------------
  165. //    DoError
  166. //----------------------------------------------------------------------------------------
  167. inline FW_AlertResult FW_CAlert::DoError(const FW_CString& documentName, const FW_CString& message)
  168. {
  169.     return DoAlert(documentName, message, FW_kOK, FW_kStopAlert, FW_kDefaultButton1, TRUE);
  170. }
  171.  
  172. #if FW_LIB_EXPORT_PRAGMAS
  173. #pragma lib_export off
  174. #endif
  175.  
  176. #endif
  177.